<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css3结构伪类选择器</title>
    <style>
        ul li:first-child {
            background-color: skyblue;
        }
        ul li:last-child {
            background-color: orange;
        }
        ul li:nth-child(4) {
            background-color: purple;
        }
        ul li:nth-child(2n) {
            background-color: lightgray;
        }
        ul li:nth-child(2n+1) {
            background-color: white;
        }
        ul li:nth-child(even) {
            background-color: red;
        }
        ul li:nth-child(odd) {
            background-color: lightgray;
        }

        ol li:nth-child(-n+3) {
            background-color: red;
        }

        section div:nth-child(1) {
            background-color: red;
        }
    </style>
</head>
<body>
    <ul>
        <li>小猪1</li>
        <li>小猪2</li>
        <li>小猪3</li>
        <li>小猪4</li>
        <li>小猪5</li>
        <li>小猪6</li>
        <li>小猪7</li>
        <li>小猪8</li>
        <li>小猪9</li>
        <li>小猪10</li>
    </ul>
    <ol>
        <li>小猪1</li>
        <li>小猪2</li>
        <li>小猪3</li>
        <li>小猪4</li>
        <li>小猪5</li>
        <li>小猪6</li>
        <li>小猪7</li>
        <li>小猪8</li>
        <li>小猪9</li>
        <li>小猪10</li>
    </ol>
    <section>
        <p>好东西哦</p>
        <div>哈哈</div>
        <div>嘿嘿</div>
    </section>
</body>
</html>